Payhere api url ekata POST request ekak yawanna tiyenne. HTML form ekak hadala eka submit karanna thiyenne. Form eke action ekata danna ona Payhere API URL eka. Oyage domain eka payhere eke whitelist karanna ona kalin. ethakota oyage domain eke idan POST request yawanna puluwan. ekata aniwayen ona fields tiyenawa. (email, name, address, amount wage ewa). me tiyenne man karapu widiya.
.env file
PAYHERE_MERCHENT_ID=24333554141
PAYHERE_SECRET=8xxxxxxxxxxxxxxxxxxxxxxxxxJ7J
PAYHERE_API_URL=https://sandbox.payhere.lk/pay/checkout
config/payhere.php
return [
'api_url' => env('PAYHERE_API_URL', 'https://sandbox.payhere.lk/pay/checkout'),
'merchant_id' => env('PAYHERE_MERCHENT_ID', 'no_merchent'),
'secret' => env('PAYHERE_SECRET', 'no_secrete'),
'return_url' => env('PAYHERE_RETURN_URL', config('app.url') . '/checkout/return'),
'notify_url' => env('PAYHERE_NOTIFY_URL', config('app.url') . '/checkout/notify'),
'cancel_url' => env('PAYHERE_CANCEL_URL', config('app.url') . '/checkout/cancel'),
];
Submit Order details (amount, items, name, etc)
<form class="width:100%" method="post" action="{{ config('payhere.api_url')}}">
@csrf
<input type="hidden" name="merchant_id" value="{{ config('payhere.merchant_id') }}">
<input type="hidden" name="return_url" value="{{ config('payhere.return_url') }}">
<input type="hidden" name="cancel_url" value="{{ config('payhere.cancel_url') }}">
<input type="hidden" name="notify_url" value="{{ config('payhere.notify_url') }}">
<input type="hidden" name="order_id" value="{{ $order->reference }}">
<input type="hidden" name="items" value="My Packages">
<input type="hidden" name="currency" value="{{ $order->currency }}">
<input type="hidden" name="amount" value="{{ $order->amount }}">
<input type="hidden" name="first_name" value="{{ $order->first_name }}">
<input type="hidden" name="last_name" value="{{ $order->last_name }}">
<input type="hidden" name="email" value="{{ $order->email }}">
<input type="hidden" name="phone" value="{{ $order->phone }}">
<input type="hidden" name="address" value="{{ $order->address }}">
<input type="hidden" name="city" value="{{ $order->city }}">
<input type="hidden" name="country" value="{{ $order->country }}">
<input type="hidden" name="hash" value="{{ $order->hash }}">
<input type="submit" class="" value="Pay Now">
</form>